home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / µSim 1.1 / source / Scroll.c < prev    next >
Encoding:
Text File  |  1997-05-25  |  1.3 KB  |  62 lines  |  [TEXT/CWIE]

  1. /*
  2. Copyright © 1993-1997 Fabrizio Oddone
  3. ••• ••• ••• ••• ••• ••• ••• ••• ••• •••
  4. This source code is distributed as freeware:
  5. you may copy, exchange, modify this code.
  6. You may include this code in any kind of application: freeware,
  7. shareware, or commercial, provided that full credits are given.
  8. You may not sell or distribute this code for profit.
  9. */
  10.  
  11. //#pragma load "MacDump"
  12.  
  13. #include    "UtilsSys7.h"
  14.  
  15. #include    "Scroll.h"
  16.  
  17. #if defined(FabSystem7orlater)
  18.  
  19.  
  20.  
  21. void VScrollRect(RectPtr r, short dv)
  22. {
  23. GrafPtr    port;
  24. Rect    src, dst;
  25. short    left, top, right, bottom;
  26.  
  27. if (dv != 0) {
  28.     GetPort(&port);
  29.     left    = (*port->visRgn)->rgnBBox.left;
  30.     top        = (*port->visRgn)->rgnBBox.top;
  31.     right    = (*port->visRgn)->rgnBBox.right;
  32.     bottom    = (*port->visRgn)->rgnBBox.bottom;
  33.     if (r->left < left)        r->left = left;
  34.     if (r->top < top)        r->top = top;
  35.     if (r->right > right)    r->right = right;
  36.     if (r->bottom > bottom)    r->bottom = bottom;
  37.     
  38.     if (dv > 0) {
  39.         topLeft(src) = topLeft(*r);
  40.         src.right    = r->right;
  41.         src.bottom    = r->bottom - dv;
  42.         
  43.         dst.left    = r->left;
  44.         dst.top        = r->top + dv;
  45.         botRight(dst) = botRight(*r);
  46.         }
  47.     else {
  48.         src.left    = r->left;
  49.         src.top        = r->top - dv;
  50.         botRight(src) = botRight(*r);
  51.         
  52.         topLeft(dst) = topLeft(*r);
  53.         dst.right    = r->right;
  54.         dst.bottom    = r->bottom + dv;
  55.         }
  56.     CopyBits(&port->portBits, &port->portBits, &src, &dst, srcCopy, nil);
  57.     }
  58. }
  59.  
  60. #endif
  61.  
  62.